<!doctype html>
<html>
    
    <body>
        <h1>AjaxBridge</h1>
        <div id='buttons'></div>
        
        <script>
            
            // 调用原生
            function callNative(action, data) {
                var xhr = new window.XMLHttpRequest(),
                url = 'http://__jsbridge__';
                xhr.open('POST', url, false);
                xhr.send(JSON.stringify({
                                        action: action,
                                        data: data
                                        }));
                                        return xhr.responseText;
            }
        
        // 调用Demo
        ; (function () {
           var callbackButton = document.getElementById('buttons').appendChild(document.createElement('button'));
           callbackButton.innerHTML = 'CallNative';
           callbackButton.onclick = function (e) {
           alert(callNative("alertMessage", "Hello world!"));
           };
           })()
           
            </script>
    </body>
    
</html>
